{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import geopandas as gpd\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from shapely.geometry import shape \n",
    "import matplotlib.pyplot as plt\n",
    "import datetime\n",
    "import sys\n",
    "sys.path.append('../../Scripts/') # link to scripts\n",
    "import preprocessing.translate   # import translation scripts from preprocessing\n",
    "import utils.spatial_utils\n",
    "import utils.temporal_utils\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# path to the MTL Trajet data \n",
    "path_2016 = \"../../Data/mtl_trajet/mtl_trajet_2016.shp\"\n",
    "path_2017 = \"../../Data/mtl_trajet/trajets_mtl_trajet_2017.shp\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "############## Important ##############\n",
    "# Note: Script below is used to deal with raw MTL Trajet 2016 data ('trip final') and load into geopandas\n",
    "# Reason: the data cannot be loaded in because there are invalid geometries\n",
    "\n",
    "# ## FROM https://gis.stackexchange.com/questions/277231/geopandas-valueerror-a-linearring-must-have-at-least-3-coordinate-tuples\n",
    "# import json\n",
    "# import fiona\n",
    "# path_2016 = \"../CASA Projects/msc_dissertation_notebooks/app_route_data/MTL_Trajet_2016_SHP/trip_final/trip_final.shp\"\n",
    "# #Read data\n",
    "# collection = list(fiona.open(path_2016,'r'))\n",
    "# df1 = pd.DataFrame(collection)\n",
    "\n",
    "# #Check Geometry\n",
    "# def isvalid(geom):\n",
    "#     try:\n",
    "#         shape(geom)\n",
    "#         return 1\n",
    "#     except:\n",
    "#         return 0\n",
    "# df1['isvalid'] = df1['geometry'].apply(lambda x: isvalid(x))\n",
    "# df1 = df1[df1['isvalid'] == 1]\n",
    "# collection = json.loads(df1.to_json(orient='records'))\n",
    "\n",
    "# #Convert to geodataframe\n",
    "# gdf = gpd.GeoDataFrame.from_features(collection)\n",
    "\n",
    "## save the file\n",
    "# gdf.to_file(\"mtl_trajet/mtl_trajet_2016.shp\", encoding='utf-8')\n",
    "############## Important ##############"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Translate and Reproject the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "initialising crs\n"
     ]
    }
   ],
   "source": [
    "gdf_2016 = preprocessing.translate.translate_data(path_2016)\n",
    "gdf_2017 = preprocessing.translate.translate_data(path_2017)\n",
    "\n",
    "# initalise the CRS\n",
    "if gdf_2016.crs == {}:\n",
    "    print(\"initialising crs\")\n",
    "    gdf_2016.crs = {'init': 'epsg:4326'}\n",
    "    \n",
    "if gdf_2017.crs == {}:\n",
    "    print(\"initialising crs\")\n",
    "    gdf_2017.crs = {'init': 'epsg:4326'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "translating data\n",
      "translating data\n"
     ]
    }
   ],
   "source": [
    "# reproject data\n",
    "if not gdf_2016.crs == {'init': 'epsg:3347'}:\n",
    "    gdf_2016 = utils.spatial_utils.change_projection(gdf_2016)\n",
    "    \n",
    "if not gdf_2017.crs == {'init': 'epsg:3347'}:\n",
    "    gdf_2017 = utils.spatial_utils.change_projection(gdf_2017)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_trip</th>\n",
       "      <th>avg_speed</th>\n",
       "      <th>duration</th>\n",
       "      <th>mode</th>\n",
       "      <th>purpose</th>\n",
       "      <th>n_coord</th>\n",
       "      <th>segments</th>\n",
       "      <th>starttime</th>\n",
       "      <th>endtime</th>\n",
       "      <th>geometry</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1724206</td>\n",
       "      <td>4.4</td>\n",
       "      <td>460</td>\n",
       "      <td>walking</td>\n",
       "      <td>returning_home</td>\n",
       "      <td>12</td>\n",
       "      <td>[{\"id\": 1150192, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-07T20:37:26-04</td>\n",
       "      <td>2016-09-07T20:45:06-04</td>\n",
       "      <td>LINESTRING (7628287.236741193 1247680.17623496...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1724208</td>\n",
       "      <td>10.7</td>\n",
       "      <td>2146</td>\n",
       "      <td>combination</td>\n",
       "      <td>work</td>\n",
       "      <td>120</td>\n",
       "      <td>[{\"id\": 1140016, \"source\": \"geobase_mtl\"}, {\"i...</td>\n",
       "      <td>2016-09-08T07:43:23-04</td>\n",
       "      <td>2016-09-08T08:19:09-04</td>\n",
       "      <td>LINESTRING (7627830.06960756 1247172.275532002...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_trip  avg_speed  duration         mode         purpose  n_coord  \\\n",
       "0  1724206        4.4       460      walking  returning_home       12   \n",
       "1  1724208       10.7      2146  combination            work      120   \n",
       "\n",
       "                                            segments               starttime  \\\n",
       "0  [{\"id\": 1150192, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-07T20:37:26-04   \n",
       "1  [{\"id\": 1140016, \"source\": \"geobase_mtl\"}, {\"i...  2016-09-08T07:43:23-04   \n",
       "\n",
       "                  endtime                                           geometry  \n",
       "0  2016-09-07T20:45:06-04  LINESTRING (7628287.236741193 1247680.17623496...  \n",
       "1  2016-09-08T08:19:09-04  LINESTRING (7627830.06960756 1247172.275532002...  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2016.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id_trip</th>\n",
       "      <th>mode</th>\n",
       "      <th>purpose</th>\n",
       "      <th>starttime</th>\n",
       "      <th>endtime</th>\n",
       "      <th>geometry</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1547</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>2017-09-18 04:16:58UTC</td>\n",
       "      <td>2017-09-18 04:26:26UTC</td>\n",
       "      <td>LINESTRING (7624015.797731054 1247372.35912242...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>308312</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>2017-09-18 06:17:46UTC</td>\n",
       "      <td>2017-09-18 06:58:49UTC</td>\n",
       "      <td>LINESTRING (7624029.565886395 1247375.82561127...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id_trip  mode purpose               starttime                 endtime  \\\n",
       "0     1547  None    None  2017-09-18 04:16:58UTC  2017-09-18 04:26:26UTC   \n",
       "1   308312  None    None  2017-09-18 06:17:46UTC  2017-09-18 06:58:49UTC   \n",
       "\n",
       "                                            geometry  \n",
       "0  LINESTRING (7624015.797731054 1247372.35912242...  \n",
       "1  LINESTRING (7624029.565886395 1247375.82561127...  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2017.head(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## analyse data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "57879\n",
      "57879\n"
     ]
    }
   ],
   "source": [
    "print(len(gdf_2016.dropna(subset=['mode'])))\n",
    "print(len(gdf_2016.dropna(subset=['purpose'])))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "74218\n",
      "74218\n"
     ]
    }
   ],
   "source": [
    "print(len(gdf_2017.dropna(subset=['mode'])))\n",
    "print(len(gdf_2017.dropna(subset=['purpose'])))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "returning_home      27128\n",
       "work                19241\n",
       "leisure              9379\n",
       "shops                8554\n",
       "food_drink           3189\n",
       "education            2830\n",
       "pick_up_drop_off     1592\n",
       "other                1219\n",
       "health               1061\n",
       "not_available          25\n",
       "Name: purpose, dtype: int64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2017['purpose'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "returning_home      16187\n",
       "work                15474\n",
       "leisure              7552\n",
       "food_drink           5858\n",
       "shops                5759\n",
       "pick_up_drop_off     2521\n",
       "education            2333\n",
       "health               2195\n",
       "Name: purpose, dtype: int64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2016['purpose'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "car                      33927\n",
       "public_transport         12706\n",
       "walking                   3956\n",
       "cycling                   3830\n",
       "public_transport, car     1584\n",
       "combination               1379\n",
       "other                      497\n",
       "Name: mode, dtype: int64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2016['mode'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "car                               24744\n",
       "cycling                           13595\n",
       "public_transport                  12935\n",
       "walking                           11062\n",
       "walking, public_transport          6234\n",
       "public_transport, car               948\n",
       "car_sharing                         908\n",
       "walking, cycling                    766\n",
       "walking, public_transport, car      567\n",
       "walking, car                        494\n",
       "Name: mode, dtype: int64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2017['mode'].value_counts()[:10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Time zone changes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(gdf_2016.starttime[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Min: 2016-09-02T22:46:55-04  Max: 2016-12-14T23:31:37-05\n",
      "Min: 2017-09-18 04:16:58UTC  Max: 2017-10-18 03:50:08UTC\n"
     ]
    }
   ],
   "source": [
    "print(\"Min:\", gdf_2016.starttime.min(), \" Max:\", gdf_2016.starttime.max())\n",
    "print(\"Min:\", gdf_2017.starttime.min(), \" Max:\", gdf_2017.starttime.max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "converting start and end timestamps to datetime objects\n"
     ]
    }
   ],
   "source": [
    "if not type(gdf_2016.starttime[0]) == datetime.datetime or not type(gdf_2017.starttime[0]) == datetime.datetime:\n",
    "    print(\"converting start and end timestamps to datetime objects\")\n",
    "    gdf_2016['starttime'] = pd.to_datetime(gdf_2016['starttime'])\n",
    "    gdf_2016['endtime'] = pd.to_datetime(gdf_2016['endtime'])\n",
    "    gdf_2017['starttime'] = pd.to_datetime(gdf_2017['starttime'])\n",
    "    gdf_2017['endtime'] = pd.to_datetime(gdf_2017['endtime'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tzoffset(None, -14400)    176346\n",
       "tzoffset(None, -18000)     99278\n",
       "Name: starttime, dtype: int64"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2016['starttime'].apply(lambda dt: dt.tzinfo).value_counts()\n",
    "# 2 time zones "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "UTC    185285\n",
       "Name: starttime, dtype: int64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2017['starttime'].apply(lambda dt: dt.tzinfo).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "## replace time zone\n",
    "gdf_2016['starttime'] = gdf_2016['starttime'].apply(lambda dt: dt.replace(tzinfo=None))\n",
    "gdf_2016['endtime'] = gdf_2017['starttime'].apply(lambda dt: dt.replace(tzinfo=None))\n",
    "gdf_2017['starttime'] = gdf_2016['endtime'].apply(lambda dt: dt.replace(tzinfo=None))\n",
    "gdf_2017['endtime'] = gdf_2017['endtime'].apply(lambda dt: dt.replace(tzinfo=None))\n",
    "\n",
    "## or\n",
    "# gdf_2016 = utils.temporal_utils.remove_timezone(gdf_2016)\n",
    "# gdf_2017 = utils.temporal_utils.remove_timezone(gdf_2017)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: starttime, dtype: int64)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2016['starttime'].apply(lambda dt: dt.tzinfo).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], Name: starttime, dtype: int64)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gdf_2017['starttime'].apply(lambda dt: dt.tzinfo).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x12c97b438>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAD7CAYAAAB0d9PAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAU1UlEQVR4nO3df6zd9X3f8edrdktJM4iBC2W2O7NgbQW0NeHO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UmyTPAT1bVu0k+APzHqro6yY8Dj1TVR5a5xQXx1tMSSPLR4+0CfnIpezlD7AUeB66uqu8BJPkxYDvwb4GPL2NvK9EXGdwe+U3g00l+EfjrVfUOcNWydrYyrQbeBc4C/jRAVb2c5IeWtasxGBRL42ngdxn9e6s+tMS9nAk2VNUxv2KuBcZtST69TD2tZB+uql9s2/8+yWeBx5N8cjmbWqG+ADyd5OvATwO3ASSZAA4vZ2Pj8NbTEkjyLPALVfXiiH2vVNX6EcN0HEm+AvxnYE9Vvd5qFwF/C/h4Vf3sMra34iR5Hri8qv5kqLYd+Azwwao67m8V1Q9KcjnwE8CzVfWd5e5nMbiYvTT+Ccc/17+yhH2cKf4acD7wu0kOJzkMfBU4D7h+ORtbof4D8DPDharaA/w68P1l6WgFq6qDVbXvTAkJ8Ipi2SX55ar64nL3cabwfC4uz6fAoFh2SV6uqh9f7j7OFJ7PxeX5FLiYvSSS/P7xdgEXLWUvZwLP5+LyfOpEDIqlcRGwBTgyrx7gvy19Oyue53NxeT7VZVAsjd9m8PTIt+fvSPLVpW9nxfN8Li7Pp7pco5Akdfl4rCSpy6CQJHUZFJKkLoNCktRlUEiSuv4/BZc578N9p5kAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "gdf_2016['starttime'].apply(lambda dt: dt.month).value_counts().plot(kind='bar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x12c824358>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAD7CAYAAAB0d9PAAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhc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KXQSFJ6jIoJEldBoUkqcugkCR1GRSSpC6DQpLUZVBIkroMCklSl0EhSeoyKCRJXQaFJKnLoJAkdRkUkqQug0KS1HVJBEWSrUleSzKbZNek+5Gky8lFHxRJVgH/Bvgx4Fbg80lunWxXknT5uOiDAtgEzFbV71TVHwPPANsm3JMkXTZWT7qBc7AWeGvo8xzwmeEBSXYCO9vHP0ry2gr1djm4Dvj9STdxNtk76Q40IRf9389L6O/mnz7TiUshKLJErRZ9qNoH7FuZdi4vSWaqauOk+5CW4t/PlXEp3HqaA24a+rwOeHtCvUjSZedSCIqvARuS3Jzk+4Fp4NCEe5Kky8ZFf+upqk4n+XvAl4FVwBNVdWzCbV1OvKWni5l/P1dAqursoyRJl61L4daTJGmCDApJUpdBIUnquug3syUJIMmfBf4Wg8flTwOvA1+qqncn2thlwCsKSRe9JD8H/FvgE8BfAa5kEBgvJrlrgq1dFnzqSd+V5GpgN3A3MNXKJ4DngIeq6g8m1Zsub0leBv5SVX2Y5JPAf6yqu5L8EPBcVX16wi1+rHlFoWEHgFPAXVV1bVVdC/yNVvt3E+1M+v+3yq8A/iRAVb0JfN/EOrpMGBQatr6q9lbVdxYKVfWdqtoL/NAE+5K+AHwtyT7gReBfAySZAk5OsrHLgbee9F1JvgL8Z2B/Vb3TajcAPw38zar60Qm2p8tcktuAHwa+VVXfnnQ/lxODQt+VZA2wi8H/7+P6Vn6HwX9b66GqOjWp3iRNjkGhc5LkZ6rqlyfdh6SVZ1DonCR5s6rcp5AuQ/7gTt+V5LfPdAq4YSV7kXTxMCg07AZgC4PHYYcF+G8r346ki4FBoWG/Bnyqqr45eiLJV1e+HUkXA/coJEld/uBOktRlUEiSugwKSVKXQSFJ6jIoJEld/w8GBB6hKFOwQwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "gdf_2017['starttime'].apply(lambda a: a.month).value_counts().plot(kind='bar')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Months for 2016:\n",
      " 11    137037\n",
      "10    133795\n",
      "12      4462\n",
      "9        330\n",
      "Name: starttime, dtype: int64 \n",
      "\n",
      "Months for 2017:\n",
      " 10    128148\n",
      "9      57137\n",
      "Name: starttime, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "print(\"Months for 2016:\\n\", gdf_2016['starttime'].apply(lambda a: a.month).value_counts(), \"\\n\")\n",
    "print(\"Months for 2017:\\n\", gdf_2017['starttime'].apply(lambda a: a.month).value_counts())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## save file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [],
   "source": [
    "## convert datetime back to string\n",
    "gdf_2016['starttime'] = gdf_2016['starttime'].astype(str)\n",
    "gdf_2016['endtime'] = gdf_2016['endtime'].astype(str)\n",
    "gdf_2017['starttime'] = gdf_2017['starttime'].astype(str)\n",
    "gdf_2017['endtime'] = gdf_2017['endtime'].astype(str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "# gdf_2016.to_file(\"../../Data/mtl_trajet/mtl_trajet_2016_translated.shp\", encoding='utf-8')\n",
    "# gdf_2017.to_file(\"../../Data/mtl_trajet/mtl_trajet_2017_translated.shp\", encoding='utf-8')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
